home *** CD-ROM | disk | FTP | other *** search
-
- /*
- File: RampLibrary.c
-
- Contains: ramp library - gxShape library
-
- Written by: Cary Clark, Georgiann Delaney, Michael Fairman, Dave Good, Robert Johnson, Keith McGreggor, Oliver Steele, David Van Brink, Chris Yerga
-
- Copyright: © 1995 by Apple Computer, Inc., all rights reserved.
-
- Change History (most recent first):
-
- <1> 1/9/95 JD First checked in.
- */
-
- #include "GraphicsLibraries.h"
-
- static gxBitmap rampBits = {nil, 1, 0, 0, 32, gxNoSpace, nil, nil};
-
- gxShape NewRamp(register const gxColor *start, register const gxColor *end, register long count, const gxRectangle *bounds)
- {
- if (count == 0)
- count = 256;
- rampBits.height = count--;
- { register gxShape rampShape = GXNewBitmap(&rampBits, nil);
- register long d1 = ((long) end->element.component[0] - (long) start->element.component[0]) / count;
- register long d2 = ((long) end->element.component[1] - (long) start->element.component[1]) / count;
- register long d3 = ((long) end->element.component[2] - (long) start->element.component[2]) / count;
- register long d4 = ((long) end->element.component[3] - (long) start->element.component[3]) / count;
- gxColor accum;
-
- accum = *end;
- do {
- GXSetShapePixel(rampShape, 0, count, &accum, 0);
- accum.element.component[0] -= d1;
- accum.element.component[1] -= d2;
- accum.element.component[2] -= d3;
- accum.element.component[3] -= d4;
- } while (--count >= 0);
- if (bounds)
- GXSetShapeBounds(rampShape, bounds);
- return rampShape;
- }
- }
-
-
- void DrawRamp(const gxColor *start, const gxColor *end, long count, const gxRectangle *bounds)
- {
- register gxShape ramp = NewRamp(start, end, count, bounds);
-
- GXDrawShape(ramp);
- GXDisposeShape(ramp);
- }
-
-
- gxShape NewCommonRamp(commonColor start, commonColor end, long count, const gxRectangle *bounds)
- {
- gxColor startColor, endColor;
-
- return NewRamp(SetCommonColor(&startColor, start), SetCommonColor(&endColor, end), count, bounds);
- }
-
-
- void DrawCommonRamp(commonColor start, commonColor end, long count, const gxRectangle *bounds)
- {
- register gxShape ramp = NewCommonRamp(start, end, count, bounds);
-
- GXDrawShape(ramp);
- GXDisposeShape(ramp);
- }
-